﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Word;

namespace docent.Addin
{
    public static class ApplicationX
    {
        public static void Init(this Application application)
        {
            application.DocumentChange += new ApplicationEvents4_DocumentChangeEventHandler(application_DocumentChange);
            application.DocumentOpen += new ApplicationEvents4_DocumentOpenEventHandler(application_DocumentOpen);
            ((ApplicationEvents4_Event)application).NewDocument += new ApplicationEvents4_NewDocumentEventHandler(ApplicationX_NewDocument);
            application.WindowActivate += new ApplicationEvents4_WindowActivateEventHandler(application_WindowActivate);

            UIManager.Instance.Load();
        }

        static void ApplicationX_NewDocument(Microsoft.Office.Interop.Word.Document Doc)
        {
            UIManager.Instance.DocPane();
        }

        static void application_WindowActivate(Microsoft.Office.Interop.Word.Document Doc, Window Wn)
        {
            UIManager.Instance.SyncState();
        }

        private static void application_DocumentOpen(Microsoft.Office.Interop.Word.Document Doc)
        {
            UIManager.Instance.DocPane();
        }

        private static void application_DocumentChange()
        {
            UIManager.Instance.GCPanes();
        }
    }
}
